﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="visualizzaArticoli.aspx.cs" Inherits="index" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="distrilan" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it" lang="it">
<head>
    <title>Distrilan Srl - visualizzazione articoli per famiglie</title>
    <link rel="shortcut icon" href="public/immagini_azienda/favicon.ico">
    <meta name="description" content=" .... "/>              
    <link href="css/stile.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="js/prototype.js"></script>
    <script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
    <script type="text/javascript" src="js/lightbox.js"></script>
    <link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />
    <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
    <!---analitycs-->
    <script type="text/javascript">
      var _gaq = _gaq || [];
      _gaq.push(['_setAccount', 'UA-8967884-9']);
      _gaq.push(['_trackPageview']);
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
    </script>
    <!---fine analitycs-->
    
    <!--
    <script type="text/javascript">
      function testForClick(e)
      {

      }
    </script>-->
    
    <script src="http://86138.hittail.com/mlt.js" type="text/javascript"></script>
    
    <script language="javascript">
    <!--
    function redirectArticoli(event) 
    {
      //mi salvo l'ultimo elemento premuto all'interno della textbox, in modo da sapere se è un invio 
      //poi nel Page_Load nel caso sia un invio e faccio la redirezione 
      document.getElementById('hfRedirect').value = event.keyCode 
    }
    //-->
    </script>
</head>
    <body>
    <form runat="server" id="formHome">
    <asp:ScriptManager ID="scriptMGR_Seleziona_Articoli" runat="server"></asp:ScriptManager>
    <asp:HiddenField ID="hfRedirect" runat="server"/>
        <div id="contenitore">		
            <div id="header">
	           <a class="logoHeader" href="index.aspx"><img src="images/static/logo-distrilan.jpg" alt="logo distrilan" title="logo distrilan"/></a>
                <a href="#" onclick="window.open('http://www.facebook.com/?ref=hpskip#!/pages/Distrilan-Srl-Distribution-Communication-Technology/185819734768743','_blank');"><img class="logoHeaderFacebook" src="images/static/Logo_FB.jpg" alt="vai al nostro facebook" title="facebook"/></a>
                <a href="#" onclick="window.open('https://www.youtube.com/user/Distrilan','_blank');"><img class="logoHeaderFacebook" src="images/static/Logo_you_tube.jpg" alt="vai al nostro youtue" title="vai al nostro youtue"/></a>
    
                <div class="pulsantiera">
        
                    <a class="linkHome" href="index.aspx"><img src="images/static/pulsanteHome.jpg"  border="0px"/></a>
                    <ul>
                        <li><a class="linkPulsantiera" href="index.aspx">HOME</a></li>
                        <li><a class="linkPulsantiera" href="azienda.aspx">AZIENDA</a></li>
                        <li><a class="linkPulsantiera" href="contatti.aspx">DOVE SIAMO</a></li>
                        <% 
                          if (distrilan.SiteUser.IsLogged() == false)
                          {
                        %>
                        <li><a class="linkPulsantiera" href="registrati.aspx">REGISTRATI</a></li>
                        <%}
                          if (distrilan.SiteUser.IsLogged() == true)
                          { 
                          %>
                        <li><asp:LinkButton ID="LinkButton1" runat="server" CssClass="linkPulsantiera" OnClick="log_out" Text="ESCI"></asp:LinkButton></li>
                          <% 
                          }
                          try
                          {
                            //provo a prendere l'username, se ce lo ho significa che sono loggato e posso fare vedere se c'è il checkout articoli
                            String username = distrilan.SiteUser.getUser().Username;
                            if (distrilan.Carrello.LeggiCarrello().Rows.Count != 0)
                            {
                            %>
                            <li><a class="linkPulsantiera" style="color:Orange" href="checkOutCarrello.aspx">IL TUO CARRELLO</a></li>
                            <% 
                            }
                          }
                          catch (Exception)
                          { }
                        %>
                    </ul>
        
                    <div class="ricercaHome">
                      <asp:UpdatePanel runat="server" ID="updPnlRicerca">
                        <ContentTemplate>
                          <asp:TextBox ID="txtBoxRicercaHome" onkeydown="redirectArticoli(event);" BorderWidth="0" runat="server"></asp:TextBox>
                          <asp:LinkButton ID="lnkBtntxtBoxRicercaHome" runat="server" OnClick="lnkBtntxtBoxRicercaHome_Click">cerca</asp:LinkButton>
                        </ContentTemplate>
                      </asp:UpdatePanel>
                    </div>
                    
                </div>
                
		    </div>	        
	        
	        <div id="corpo">	         
			    
		        <div id="navigazione">

		            <%
		            //se l'utente non è loggato allora facciamo vedere il box di login
                if (distrilan.SiteUser.IsLogged() == false)
                {            
		            %>                		            
		            <div class="areaRiservataHome">
	                <div class="headerAreaRiservata">&nbsp;Area Riservata</div>
                  <asp:Label ID="lblLogin" runat="server" Text="Username" CssClass="lblAreaRis"></asp:Label>
                  <asp:TextBox ID="txtBoxLogin" runat="server" CssClass="txtBoxAreaRis"></asp:TextBox><br />
                  <asp:Label ID="LblPwd" runat="server" Text="Password" CssClass="lblAreaRis"></asp:Label>
                  <asp:TextBox ID="txtBoxPwd" runat="server" TextMode="Password" CssClass="txtBoxAreaRis"></asp:TextBox><br />
                  <asp:Button ID="Button1" runat="server" Text="Accedi" CssClass="btnLogin" OnClick="Button1_Click"/>
                </div>
		            <%
                }
		            %>
            		<asp:Label ID="lblUsername" runat="server"></asp:Label>  
            		
                <% 
                if (distrilan.SiteUser.IsLogged() == true)
                {
			          %>
			          <br /><br />
			          <asp:Panel ID="PanelPulsanti" CssClass="pnlPulsanti" runat="server">
			            <div class="boxPulsante"><img src="images/static/telefono.jpg"/><a href="articoli.aspx?filtroFamiglia=1">Telephony Solutions</a></div>
			            <div class="boxPulsante"><img src="images/static/networking.jpg"/><a href="articoli.aspx?filtroFamiglia=2">Networking</a></div>
			            <div class="boxPulsante"><img src="images/static/cabling.jpg"/><a href="articoli.aspx?filtroFamiglia=3">Cabling</a></div>
			            <div class="boxPulsante"><img src="images/static/multifunzione_panasonic.jpg"/><a href="articoli.aspx?filtroFamiglia=4">Office Machines</a></div>
			            <div class="boxPulsante"><img src="images/static/videosorveglianza.jpg"/><a href="articoli.aspx?filtroFamiglia=5">Video & Security Systems</a></div>
			            <div class="boxPulsante"><img src="images/static/servizi.jpg"/><a href="articoli.aspx?filtroFamiglia=9">Servizi</a></div>
			            <br />
			          </asp:Panel>
			           <%
			            }
			           %>                
            		
			        <ul>
			            <li><a href="vendor.aspx">Marchi distribuiti</a></li>
                        <li><a href="<%= distrilan.Utility.GetHrefDownload() %>">Listino</a></li>
                       <%-- <%if (SiteUser.IsLogged())
                        {
                            %>
                            <li><a href="download.aspx">Listino</a></li>
                            <%
                        }
                        else
                        { 
                            %>
                            <li><a href="registrati.aspx">Listino</a></li>
                            <%
                        }
                        %>--%>
			            <li><a href="privacy.aspx">Privacy</a></li>
			            <li><a href="condizioni_di_vendita.aspx">Condizioni di vendita</a></li>
			            <li><a href="promo.aspx">Promozioni</a></li>
			            
			            <%
			            //se l'utente è loggato faccio vedere la sezione download      
			            if(distrilan.SiteUser.IsLogged() == true)
                        {
			            %>
			            <li><a href="download.aspx">Download</a></li>
			            <%
			            }
			            %>
			        </ul>
		        </div>	

		         <div id="contenuto">
			        <div class="headerContenuto">Lista Articoli</div>

			        <asp:Label runat="server" ID="lblMessage"></asp:Label>
               
                    <asp:Panel ID="panelLinkReturn" runat="server"></asp:Panel>
               
                    <asp:GridView onkeypress="testForClick(event)"  ID="GridViewVisualizzaArticoli" runat="server" AutoGenerateColumns="False" DataKeyNames="codart" AllowPaging="True" PageSize="20" PagerStyle-CssClass="PagerStyle" DataSourceID="SqlDataSourceVisualizzaArticoli" OnRowCommand="GridViewVisualizzaArticoli_RowCommand" PagerStyle-Font-Size="17px" BorderColor="#E2E2E2" BorderWidth="1px" >
                    <Columns>
                              
                        <asp:TemplateField HeaderText="Codice e Descrizione">
                            <ItemTemplate>
                                <br />
                                <asp:Label Text="Codice: " runat="server" />
                                <asp:Label ID="lblCodart" runat="server" Text=<%# Eval("codart").ToString()%> CssClass="strong"/><br /><br />
                                <asp:Label ID="lblDescrizione" Text=<%# Eval("descri").ToString()%> runat="server" /><br /><br />
                                <asp:Label Text="Note: " CssClass="red" runat="server" />
                                <asp:Label ID="lblNote" Text=<%# Eval("note").ToString()%> CssClass="strong" runat="server" />
                                <br /><br />
                            </ItemTemplate>
                        </asp:TemplateField>      
                              
                        <%--<asp:BoundField DataField="codart" HeaderText="Codice articolo" SortExpression="codart" />
                        <asp:BoundField ItemStyle-CssClass="txtDescrizioneArticoli" DataField="descri" HeaderText="Descrizione" SortExpression="descri" />--%>
                        
                        <asp:BoundField DataField="prezzo" HeaderText="Prezzo listino iva esc €" SortExpression="prezzo" >
                           <ItemStyle CssClass="txtAlgCtr" />
                        </asp:BoundField>
                   
                        <asp:TemplateField HeaderText="Sconto %">
                           <ItemTemplate>
                              <asp:Label ID="sconto" runat="server" Text=<%# distrilan.SiteUser.IsLogged() ? scriviSconto(distrilan.SiteUser.getUser().Username, Eval("codart").ToString()) : scriviSconto("null", Eval("codart").ToString())%>></asp:Label>
                           </ItemTemplate>
                           <ControlStyle Width="60px" />
                           <ItemStyle CssClass="txtAlgCtr" />
                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Prezzo<br/> scontato iva esc €">
                           <ItemTemplate>
                             <asp:Label ID="prz" runat="server" Text=<%# distrilan.SiteUser.IsLogged() ? calcolaPrezzo(distrilan.SiteUser.getUser().Username, Eval("codart").ToString()) : calcolaPrezzo("null", Eval("codart").ToString())%>></asp:Label>
                           </ItemTemplate>
                            <ItemStyle CssClass="txtAlgCtr" />
                        </asp:TemplateField>
      
                        <asp:TemplateField HeaderText="Vendor">
                           <ItemTemplate>
                             <asp:Image runat="server" ImageUrl=<%# File.Exists(Server.MapPath("public/marchi/"+Eval("nomeVendor")+"-mini.jpg"))?"public/marchi/"+Eval("nomeVendor")+"-mini.jpg":"immagini/vendor/logo.jpg"%>/>
                           </ItemTemplate>
                        </asp:TemplateField>                                       
                   
                        <asp:TemplateField HeaderText="Qty">
                           <ItemTemplate>
                             <asp:TextBox ID="txtQty" runat="server" Width="25px" MaxLength="3" />
                           </ItemTemplate>
                        </asp:TemplateField>
 
                        <asp:TemplateField>
                          <ItemTemplate>
                            <asp:ImageButton ID="AddButton"  runat="server" CommandName="AddToCart" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" ImageUrl="~/images/static/addtocart.gif"/>
                          </ItemTemplate> 
                        </asp:TemplateField> 

                        <asp:TemplateField HeaderText="Img">
                           <ItemTemplate>
                                <%# File.Exists(Server.MapPath("public/articoli/" +Eval("codart") + "/" +Eval("codart") +"-mini.jpg"))? "<a title=\"codice articolo:"+  Eval("codart")+"\" rel=\"lightbox[distrilan]\" href=\"public/articoli/"+Eval("codart")+ "/"+ Eval("codart") +".jpg\"> <img src=\"public/articoli/"+Eval("codart") +"/"+Eval("codart") +"-mini.jpg\" /> </a>": "<img src=\"images/static/imgArticoloNonPresente.png\"/>"%>
                           </ItemTemplate>
                        </asp:TemplateField>                                                         
                    
                        <asp:TemplateField HeaderText="Pdf">
                         <ItemTemplate>
                           <%# File.Exists(Server.MapPath("public/articoli/" + Eval("codart") + "/" + Eval("codart") + ".pdf")) ? "<a href=\"#\" onClick=\"window.open('public/articoli/" + Eval("codart") + "/" + Eval("codart") + ".pdf','_blank','width=900,resizable=yes')\"><img src=\"images/static/pdf.png\"/></a>" : "<img src=\"images/static/pdfNonPresente.png\">"%>
                         </ItemTemplate>
                        </asp:TemplateField>

                </Columns>
                    <AlternatingRowStyle BackColor="#E0E0E0"/>
                    <RowStyle BackColor="#F4F4F4" />
                </asp:GridView>
               
               <asp:SqlDataSource ID="SqlDataSourceVisualizzaArticoli" runat="server" ConnectionString="<%$ ConnectionStrings:ConnStr %>"></asp:SqlDataSource>
	   
	            
	            </div><!--FINE DEL TAG CONTENUTO-->
    	    </div>			
    	    
    	    <!--div per allungamento pagina in tutti i browser-->
    	    <div style="clear:both; height:20px; overflow:hidden"></div>
            
            <div id="footer">
                <div class="containerTextFooter">
                    <div class="textFooter">&copy 2010 DISTRILAN S.R.L. Vicolo San Giorgio n°5 20090 Buccinasco (MI) C.F e P.IVA 06619770966 <!-- <a href="http://www.mcsoftwaresolutions.net/passepartout.html">Passepartout</a></div> -->
                </div>
            </div>
            
        </div>
        
    </form>	
    </body>
</html>
